<!--项目详情-计划-详细信息-->
<template>
  <div class="base-info">
    <div class="info"></div>
    <BaseInfo :="$attrs" :formList="formList"></BaseInfo>
  </div>
</template>

<script setup>
import { useConvertForm } from '@/hooks';
import BaseInfo from '@/views/components/baseInfo.vue';

const route = useRoute();
const { commonApi } = window.$api;
const formList = ref([]);
const topInfo = ref([]);

onMounted(() => {
  getInfoLayout();
});

/**
 * 获取详情
 * */
const getInfoLayout = () => {
  const params = {
    serviceKey: 'Default',
    oid: route.query.oid,
  };
  commonApi.getInfoLayout(params).then((res) => {
    const currFormList = [];
    res.data.map((item) => {
      if (item.groupName === '常规') {
        const rows = Array.from(new Set(item.items.map((el) => el.row)));
        rows.map((row) => {
          const arr = item.items.filter((el) => el.row === row);
          topInfo.value.push(arr);
        });
      } else {
        currFormList.push(item);
      }
    });
    formList.value = useConvertForm(currFormList);
  });
};
</script>

<style lang="less" scoped>
.base-info {
  background-color: var(--el-fill-color-blank);
  .info {
    display: flex;
    padding: 10px 0;
    position: relative;
  }
}
</style>
